package org.github.manx98.jlibhac.tools.fssystem;

import java.io.File;
import java.util.regex.Pattern;

/**
 * @author Manx98
 * @version 1.0
 * @since 2022/10/3 14:12
 */
public class PathTools {
    public static boolean matchesPattern(String searchPattern, String name, boolean ignoreCase) {
        if (ignoreCase) {
            return Pattern.compile(searchPattern, Pattern.CASE_INSENSITIVE).matcher(name).matches();
        } else {
            return Pattern.matches(searchPattern, name);
        }
    }

    public static String combine(String path, String name) {
        if (path.endsWith("/") || name.startsWith("/")){
            return path + name;
        }else {
            return path + "/" + name;
        }
    }
}
